package com.hg.library.http;

import com.hg.library.config.HttpConfig;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;
import okhttp3.Request;

/**
 * Created by ASUS-PC on 2016/6/14.
 */
public class HttpAgent {

    private static OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .connectTimeout(HttpConfig.CONNECT_TIMEOUT, TimeUnit.MILLISECONDS)
            .readTimeout(HttpConfig.READ_TIMEOUT, TimeUnit.MILLISECONDS)
//            .addInterceptor(new HttpInterceptor())
            .build();

    public static void get(String url, RequestHandle handle) {
        okHttpClient.newCall(new Request.Builder().url(url).build()).enqueue(handle);
    }

    public static OkHttpClient getOkHttpClient(){
        return okHttpClient;
    }
}
